//
//  WikipediaViewController.m
//  SYiDaiy
//
//  Created by dllo on 16/9/3.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "WikipediaViewController.h"
#import "TAMacro.h"
#import "WikipediaTableViewCell.h"
#import "WikipediaDetailViewController.h"

@interface WikipediaViewController ()<UITableViewDataSource,UITableViewDelegate>

@end

@implementation WikipediaViewController
#pragma mark -----视图加载
- (void)viewDidLoad {
    [super viewDidLoad];

    UITableView *wikipediaTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 120) style:UITableViewStyleGrouped];
    wikipediaTableView.delegate = self;
    wikipediaTableView.dataSource = self;
    [self.view addSubview:wikipediaTableView];
    [wikipediaTableView registerClass:[WikipediaTableViewCell class] forCellReuseIdentifier:@"wikipediaTableViewCell"];
    
    
}
#pragma mark -----tableview返回cell的方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    WikipediaTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"wikipediaTableViewCell"];
    cell.backgroundColor = [UIColor whiteColor];
    NSInteger row = [indexPath row];
    Wikipediaesarray *wikipediaesarray = [_wikipedArray objectAtIndex:row];
    cell.imageView1.image = [UIImage imageNamed:@"IconBooks"];
    cell.titleLabel.text = wikipediaesarray.title;
    cell.pubdateLabel.text = wikipediaesarray.pubdate;
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}
#pragma mark -----tableview的点击方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    WikipediaDetailViewController *wikiDetailVC = [WikipediaDetailViewController new];
    [self.navigationController pushViewController:wikiDetailVC animated:YES];
    NSInteger row = [indexPath row];
    wikiDetailVC.wikipedArray = _wikipedArray;
    
    [wikiDetailVC setRowValue:row];
    
    
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
